package org.jeecg.modules.zonglzp.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.zonglzp.entity.ProductEntity;
import org.jeecg.modules.zonglzp.mapper.ProductMapper;
import org.jeecg.modules.zonglzp.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {


    @Autowired
    ProductMapper mapper;


    // 查询产品
    @Override
    public IPage<ProductEntity> getProductlist(Page<ProductEntity> page, String productCode, int productType, int sex) {
        return mapper.getProductlist(page, productCode, productType, sex);
    }

    //将产品id和部门id插进产品客户部门关联表中
    @Override
    public int addProductToDepart(String remark, String productId, String customerDepartId, int numbers) {

        return mapper.addProductToDepart(remark, productId, customerDepartId, new Date(), numbers);
    }

    //修改产品信息了就
    @Override
    public void updateProduct(String fabricId, String xiuziZiti, String xiuziColor, String xiuziWeizhi, String xiuziTwoNeirong, String xiuziOneNeirong, String productId) {
        mapper.updateProduct(fabricId, xiuziZiti, xiuziColor, xiuziWeizhi, xiuziTwoNeirong, xiuziOneNeirong, productId, new Date());
    }

    //查询部门
    @Override
    public IPage<ProductEntity> getDepartProductlist(Page<ProductEntity> page, String departId) {
        return mapper.getDepartProductlist(page, departId);
    }


    //查询是否是公司
    @Override
    public int getIsconpangy(String customerDepartId) {
        return mapper.getIsconpangy(customerDepartId);
    }

    //查询已经存在的件数
    @Override
    public int queryproductNumber(String productId, String customerDepartId) {
        return mapper.queryproductNumber(productId, customerDepartId);
    }

    //查询是否有产品之前该部门
    @Override
    public String queryproductdepart(String productId, String customerDepartId) {
        return mapper.queryproductdepart(productId, customerDepartId);
    }

    @Override
    public void updateNumber(String productId, String customerDepartId, int i) {
        mapper.updateNumber(productId, customerDepartId, i);
    }

    //查询现货的所有产品
    @Override
    public List<ProductEntity> getxianshuoproductList() {
        return mapper.getxianshuoproductList();
    }
}
